package com.shuyuntu.login.service;

import com.shuyuntu.login.entity.User;
import com.shuyuntu.login.dao.UserDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @program: login
 * @Date: 2018-07-11 17:10
 * @Author: Mr.Deng
 * @Description:
 */
@Service
public class UserService {
    @Autowired
    private UserDao userdao;

    public boolean verifyUser(User user) {
        if (userdao.findByNameAndPassword(user.getName(), user.getPassword()).isEmpty()) {
            return false;
        } else {
            return true;
        }
    }

    public String registerUser(User user) {


        if (userdao.findByName(user.getName()).isEmpty()) {
            userdao.save(user);
            return "用户名  " + user.getName() + " 注册成功";
        } else {
            return "用户名 " + user.getName() + "已被占用！";
        }
    }



}
